**for REStat paper, "Breastfeeding and Children's Early Cognitive Outcomes."

options nocenter validvarname=any;

libname dd 'X:\Donnanew';
data x;
infile 'X:\Donnanew\bfwage08.dat' lrecl=508 missover DSD DLM=' ';
input
  A0001200
  R0000100
  R0038800
  R0536300
  R0536401
  R0536402
  R1193900
  R1200200
  R1200300
  R1201400
  R1204400
  R1204500
  R1204600
  R1204900
  R1205300
  R1205400
  R1210800
  R1235800
  R1302400
  R1302500
  R1302600
  R1302700
  R1318200
  R1482600
  R1700500
  R2992400
  R4258000
  R5915500
  S0289800
  T2009700
  T2011100
  T2015900
  T2016000
  T2016700
  T2016900
  T2017000
  T2017100
  T2017200
  T2017300
  T2017400
  T2017500
  T2017600
  T2017700
  T2017800
  T2017900
  T2018000
  T2018100
  T2018200
  T2018300
  T2018400
  T2018500
  T2018600
  T2018700
  T2018800
  T2018900
  T2019000
  T2019100
  T2019200
  T2021700
  T2021800
  T2021900
  T2022000
  T2022100
  T2022200
  T2022300
  T2022400
  T2022500
  T2022600
  T3330100
  T3330200
  T3330300
  T3330400
  T3330500
  T3330600
  T3330700
  T3330800
  T3346100
  T3346101
  T3346102
  T3346200
  T3346201
  T3346202
  T3346300
  T3346301
  T3346302
  T3346400
  T3346401
  T3346402
  T3346500
  T3346501
  T3346502
  T3346600
  T3346601
  T3346602
  T3346700
  T3346701
  T3346702
  T3346800
  T3346801
  T3346802
  T3504400
  T3504500
  T3504600
  T3504700
  T3504800
  T3504900
  T3505000
  T3505100
  T3507200
  T3507300
  T3507400
  T3507500
  T3507600
  T3507700
  T3507800
  T3507900
  T3508000
  T3508100
  T3508200
  T3508300
  T3508400
  T3508500
  T3508600
  T3508700
  Z9065300
  Z9065400
  Z9065600
  Z9065700
  Z9083800
  Z9083900
  Z9084800
  Z9084900
  Z9085000
;

  label A0001200 = "R12 RELEASE VERSION NUMBER 2008";
  label R0000100 = "PUBID - YTH ID CODE 1997";
  label R0038800 = "GRADES RCVD 8TH GRADE 1997";
  label R0536300 = "KEY!SEX (SYMBOL) 1997";
  label R0536401 = "KEY!BDATE M/Y (SYMBOL) 1997";
  label R0536402 = "KEY!BDATE M/Y (SYMBOL) 1997";
  label R1193900 = "CV_AGE(MONTHS)_INT_DATE 1997";
  label R1200200 = "CV_BIO_MOM_AGE_YOUTH 1997";
  label R1200300 = "CV_CENSUS_REGION 1997";
  label R1201400 = "CV_ENROLLSTAT 1997";
  label R1204400 = "CV_HGC_EVER 1997";
  label R1204500 = "CV_INCOME_GROSS_YR 1997";
  label R1204600 = "CV_HH_INCOME_SOURCE 1997";
  label R1204900 = "CV_HH_POV_RATIO 1997";
  label R1205300 = "CV_YTH_REL_HH_CURRENT 1997";
  label R1205400 = "CV_HH_SIZE 1997";
  label R1210800 = "CV_PIAT_STANDARD_SCORE 1997";
  label R1235800 = "CV_SAMPLE_TYPE 1997";
  label R1302400 = "CV_HGC_BIO_DAD 1997";
  label R1302500 = "CV_HGC_BIO_MOM 1997";
  label R1302600 = "CV_HGC_RES_DAD 1997";
  label R1302700 = "CV_HGC_RES_MOM 1997";
  label R1318200 = "CV_PIAT_STANDARD_UPD 1997";
  label R1482600 = "KEY!RACE_ETHNICITY (SYMBOL) 1997";
  label R1700500 = "GRADES RCVD 8TH GRADE 1998";
  label R2992400 = "GRADES RCVD 8TH GRADE 1999";
  label R4258000 = "GRADES RCVD 8TH GRADE 2000";
  label R5915500 = "GRADES RCVD 8TH GRADE 2001";
  label S0289800 = "GRADES RCVD 8TH GRADE 2002";
  label T2009700 = "CUR OR MOST RECENT JOB 2008";
  label T2011100 = "CV_AGE_INT_DATE 2008";
  label T2015900 = "CV_ENROLLSTAT 2008";
  label T2016000 = "CV_HGC_EVER 2008";
  label T2016700 = "CV_HIGHEST_DEGREE_EVER 2008";
  label T2016900 = "CV_HRLY_COMPENSATION L1 2008";
  label T2017000 = "CV_HRLY_COMPENSATION L2 2008";
  label T2017100 = "CV_HRLY_COMPENSATION L3 2008";
  label T2017200 = "CV_HRLY_COMPENSATION L4 2008";
  label T2017300 = "CV_HRLY_COMPENSATION L5 2008";
  label T2017400 = "CV_HRLY_COMPENSATION L6 2008";
  label T2017500 = "CV_HRLY_COMPENSATION L7 2008";
  label T2017600 = "CV_HRLY_COMPENSATION L8 2008";
  label T2017700 = "CV_HRLY_PAY L1 2008";
  label T2017800 = "CV_HRLY_PAY L2 2008";
  label T2017900 = "CV_HRLY_PAY L3 2008";
  label T2018000 = "CV_HRLY_PAY L4 2008";
  label T2018100 = "CV_HRLY_PAY L5 2008";
  label T2018200 = "CV_HRLY_PAY L6 2008";
  label T2018300 = "CV_HRLY_PAY L7 2008";
  label T2018400 = "CV_HRLY_PAY L8 2008";
  label T2018500 = "CV_HRS_PER_WEEK L1 2008";
  label T2018600 = "CV_HRS_PER_WEEK L2 2008";
  label T2018700 = "CV_HRS_PER_WEEK L3 2008";
  label T2018800 = "CV_HRS_PER_WEEK L4 2008";
  label T2018900 = "CV_HRS_PER_WEEK L5 2008";
  label T2019000 = "CV_HRS_PER_WEEK L6 2008";
  label T2019100 = "CV_HRS_PER_WEEK L7 2008";
  label T2019200 = "CV_HRS_PER_WEEK L8 2008";
  label T2021700 = "CV_WKSWK_JOB_DLI L1 2008";
  label T2021800 = "CV_WKSWK_JOB_DLI L2 2008";
  label T2021900 = "CV_WKSWK_JOB_DLI L3 2008";
  label T2022000 = "CV_WKSWK_JOB_DLI L4 2008";
  label T2022100 = "CV_WKSWK_JOB_DLI L5 2008";
  label T2022200 = "CV_WKSWK_JOB_DLI L6 2008";
  label T2022300 = "CV_WKSWK_JOB_DLI L7 2008";
  label T2022400 = "CV_WKSWK_JOB_DLI L8 2008";
  label T2022500 = "R12 SAMPLE WEIGHT CC 2008";
  label T2022600 = "R12 SAMPLE WEIGHT PANEL 2008";
  label T3330100 = "YEMP CURFLAG (ROS ITEM) L1 2008";
  label T3330200 = "YEMP CURFLAG (ROS ITEM) L2 2008";
  label T3330300 = "YEMP CURFLAG (ROS ITEM) L3 2008";
  label T3330400 = "YEMP CURFLAG (ROS ITEM) L4 2008";
  label T3330500 = "YEMP CURFLAG (ROS ITEM) L5 2008";
  label T3330600 = "YEMP CURFLAG (ROS ITEM) L6 2008";
  label T3330700 = "YEMP CURFLAG (ROS ITEM) L7 2008";
  label T3330800 = "YEMP CURFLAG (ROS ITEM) L8 2008";
  label T3346100 = "YEMP STOPDATE (ROS ITEM) L1 2008";
  label T3346101 = "YEMP STOPDATE (ROS ITEM) L1 2008";
  label T3346102 = "YEMP STOPDATE (ROS ITEM) L1 2008";
  label T3346200 = "YEMP STOPDATE (ROS ITEM) L2 2008";
  label T3346201 = "YEMP STOPDATE (ROS ITEM) L2 2008";
  label T3346202 = "YEMP STOPDATE (ROS ITEM) L2 2008";
  label T3346300 = "YEMP STOPDATE (ROS ITEM) L3 2008";
  label T3346301 = "YEMP STOPDATE (ROS ITEM) L3 2008";
  label T3346302 = "YEMP STOPDATE (ROS ITEM) L3 2008";
  label T3346400 = "YEMP STOPDATE (ROS ITEM) L4 2008";
  label T3346401 = "YEMP STOPDATE (ROS ITEM) L4 2008";
  label T3346402 = "YEMP STOPDATE (ROS ITEM) L4 2008";
  label T3346500 = "YEMP STOPDATE (ROS ITEM) L5 2008";
  label T3346501 = "YEMP STOPDATE (ROS ITEM) L5 2008";
  label T3346502 = "YEMP STOPDATE (ROS ITEM) L5 2008";
  label T3346600 = "YEMP STOPDATE (ROS ITEM) L6 2008";
  label T3346601 = "YEMP STOPDATE (ROS ITEM) L6 2008";
  label T3346602 = "YEMP STOPDATE (ROS ITEM) L6 2008";
  label T3346700 = "YEMP STOPDATE (ROS ITEM) L7 2008";
  label T3346701 = "YEMP STOPDATE (ROS ITEM) L7 2008";
  label T3346702 = "YEMP STOPDATE (ROS ITEM) L7 2008";
  label T3346800 = "YEMP STOPDATE (ROS ITEM) L8 2008";
  label T3346801 = "YEMP STOPDATE (ROS ITEM) L8 2008";
  label T3346802 = "YEMP STOPDATE (ROS ITEM) L8 2008";
  label T3504400 = "YEMP MILFLAG (ROS ITEM) L1 2008";
  label T3504500 = "YEMP MILFLAG (ROS ITEM) L2 2008";
  label T3504600 = "YEMP MILFLAG (ROS ITEM) L3 2008";
  label T3504700 = "YEMP MILFLAG (ROS ITEM) L4 2008";
  label T3504800 = "YEMP MILFLAG (ROS ITEM) L5 2008";
  label T3504900 = "YEMP MILFLAG (ROS ITEM) L6 2008";
  label T3505000 = "YEMP MILFLAG (ROS ITEM) L7 2008";
  label T3505100 = "YEMP MILFLAG (ROS ITEM) L8 2008";
  label T3507200 = "YEMP SELF EMPLOYED (ROS ITEM) L1 2008";
  label T3507300 = "YEMP SELF EMPLOYED (ROS ITEM) L2 2008";
  label T3507400 = "YEMP SELF EMPLOYED (ROS ITEM) L3 2008";
  label T3507500 = "YEMP SELF EMPLOYED (ROS ITEM) L4 2008";
  label T3507600 = "YEMP SELF EMPLOYED (ROS ITEM) L5 2008";
  label T3507700 = "YEMP SELF EMPLOYED (ROS ITEM) L6 2008";
  label T3507800 = "YEMP SELF EMPLOYED (ROS ITEM) L7 2008";
  label T3507900 = "YEMP SELF EMPLOYED (ROS ITEM) L8 2008";
  label T3508000 = "YEMP ASSIGNMENT (ROS ITEM) L1 2008";
  label T3508100 = "YEMP ASSIGNMENT (ROS ITEM) L2 2008";
  label T3508200 = "YEMP ASSIGNMENT (ROS ITEM) L3 2008";
  label T3508300 = "YEMP ASSIGNMENT (ROS ITEM) L4 2008";
  label T3508400 = "YEMP ASSIGNMENT (ROS ITEM) L5 2008";
  label T3508500 = "YEMP ASSIGNMENT (ROS ITEM) L6 2008";
  label T3508600 = "YEMP ASSIGNMENT (ROS ITEM) L7 2008";
  label T3508700 = "YEMP ASSIGNMENT (ROS ITEM) L8 2008";
  label Z9065300 = "CVC_WKSWK_ADULT_ET";
  label Z9065400 = "CVC_WKSWK_ADULT_ALL";
  label Z9065600 = "CVC_HOURS_WK_ADULT_ET";
  label Z9065700 = "CVC_HOURS_WK_ADULT";
  label Z9083800 = "CVC_HGC_EVER";
  label Z9083900 = "CVC_HIGHEST_DEGREE_EVER";
  label Z9084800 = "CVC_HS_LEFT_DATE";
  label Z9084900 = "CVC_HS_LEFT_HGC";
  label Z9085000 = "CVC_HS_LEFT_HGA";

 

  data dd.bfwage08;
  set x;
keep r0000100 piat97 piat97r hhinc97 female black hispanic b82 b83 b84
biodaded biomomed twobio97 twostp97 biom97 biod97 other97 hhsize97 regne regnc regs regw
hgc97 hgc08 age08 exp20e exp20a hours08 wage08 lnw08 agej08 wt08 lnhhinc pt08 ft08
expedv expadv famdv daddv momdv hhincdv agej24 agej25 agej26;


  *in a sense, redoing Murnane, Willett, and Levy paper with 2008
  *NLSY97 data.  contains PIAT math test;

*original normed PIAT Math standard score;
piat97 = .;
if r1210800 gt 0 then piat97 = r1210800;
piat97 = (piat97 - 100)/15;

*updated normed PIAT Math standard score;
piat97r = .;
if r1318200 gt 0 then piat97r = r1318200;
piat97r = (piat97r - 100)/15;

**rescaled so mean 0 s.d. 1;

  female = .;
  if r0536300 = 1 then female = 0;
  if r0536300 = 2 then female = 1;

  black = .;
  hispanic = .;
if r1482600 = 1 then do;
  black = 1;
  hispanic = 0;
  end;
if r1482600 = 2 then do;
  black = 0;
  hispanic = 1;
  end;
if r1482600 = 4 then do;
  black = 0;
  hispanic = 0;
  end;
*not coding mixed race;

*birth year dummy variables;
b80 = .;
b81 = .;
b82 = .;
b83 = .;
b84 = .;
if r0536402 = 1980 then do;
b80 = 1;
b81 = 0;
b82 = 0;
b83 = 0;
b84 = 0;
end;
if r0536402 = 1981 then do;
b80 = 0;
b81 = 1;
b82 = 0;
b83 = 0;
b84 = 0;
end;
if r0536402 = 1982 then do;
b80 = 0;
b81 = 0;
b82 = 1;
b83 = 0;
b84 = 0;
end;
if r0536402 = 1983 then do;
b80 = 0;
b81 = 0;
b82 = 0;
b83 = 1;
b84 = 0;
end;
if r0536402 = 1984 then do;
b80 = 0;
b81 = 0;
b82 = 0;
b83 = 0;
b84 = 1;
end;

*parental education;
biodaded = .;
if (r1302400 gt 0 and r1302400 lt 95) then biodaded = r1302400;

biomomed = .;
if (r1302500 gt 0 and r1302500 lt 95) then biomomed = r1302500;

resdaded = .;
if (r1302600 gt 0 and r1302600 lt 95) then resdaded = r1302600;

resmomed = .;
if (r1302700 gt 0 and r1302700 lt 95) then resmomed = r1302700;

*household income;
hhinc97 = .;
if (r1204500 ne -1 and r1204500 ne -2 and r1204500 ne -3 and r1204500 ne -4 and r1204500 ne -5)
then hhinc97 = r1204500;
*convert hh income to 2008 dollars (from '96);
hhinc97 = hhinc97*(215.303/156.9);
lnhhinc = .;
if hhinc97 gt 0 then lnhhinc = log(hhinc97);
if hhinc97 = 0 then lnhhinc = 0;

*family structure when took piat test;
twobio97 = .;
twostp97 = .;
biom97 = .;
biod97 = .;
other97 = .;
if (r1205300 = 1 or r1205300 = 6) then twobio97 = 1;
if twobio97 = 1 then do;
   twostp97 = 0;
   biom97 = 0;
   biod97 = 0;
   other97 = 0;
end;
if (r1205300 = 2 or r1205300 = 3) then twostp97 = 1;
if twostp97 = 1 then do;
   twobio97 = 0;
   biom97 = 0;
   biod97 = 0;
   other97 = 0;
end;
if r1205300 = 4 then biom97 = 1;
if biom97 = 1 then do;
   twobio97 = 0;
   twostp97 = 0;
   biod97 = 0;
   other97 = 0;
end;
if r1205300 = 5 then biod97 = 1;
if biod97 = 1 then do;
   twobio97 = 0;
   twostp97 = 0;
   biom97 = 0;
   other97 = 0;
end;
if (r1205300 = 7 or r1205300 = 8 or r1205300 = 9 or r1205300 = 10) then other97 = 1;
if other97 = 1 then do;
   twobio97 = 0;
   twostp97 = 0;
   biom97 = 0;
   biod97 = 0;
end;

*household size;
hhsize97 = .;
if r1205400 gt 0 then hhsize97 = r1205400;

*region when took test;
regne = .;
regnc = .;
regs = .;
regw = .;
if r1200300 = 1 then do;
regne = 1;
regnc = 0;
regs = 0;
regw = 0;
end;
if r1200300 = 2 then do;
regne = 0;
regnc = 1;
regs = 0;
regw = 0;
end;
if r1200300 = 3 then do;
regne = 0;
regnc = 0;
regs = 1;
regw = 0;
end;
if r1200300 = 4 then do;
regne = 0;
regnc = 0;
regs = 0;
regw = 1;
end;

**highest grade completed in '97;
hgc97 = .;
if r1204400 ge 0 then hgc97 = r1204400;

*highest grade completed in 2008;
hgc08 = .;
if t2016000 ge 0 and t2016000 lt 95 then hgc08 = t2016000;

*age in 08;
age08 = .;
if t2011100 gt 0 then age08 = t2011100;

*concentration of 24-26 year olds at the 2008 interview;

**experience since age 20;
*employee jobs;
exp20e = .;
if z9065300 ge 0 then exp20e = z9065300/52;
*all jobs;
exp20a = .;
if z9065400 ge 0 then exp20a = z9065400/52;

**employment info., current most recent job 2008 interview;
wage08 = .;
hours08 = .;
curr08 = .;
mo08 = .;
yr08 = .;
self08 = .;
if t2009700 = 1 then do;
   if t2017700 ge 0 then wage08 = t2017700/100;
   if t2018500 ge 0 then hours08 = t2018500;
   if t3330100 ge 0 then curr08 = t3330100;
   if t3346101 ge 0 then mo08 = t3346101;
   if t3346102 ge 0 then yr08 = t3346102;
   if t3507200 ge 0 then self08 = t3507200;
end;
if t2009700 = 2 then do;
   if t2017800 ge 0 then wage08 = t2017800/100;
   if t2018600 ge 0 then hours08 = t2018600;
   if t3330200 ge 0 then curr08 = t3330200;
   if t3346201 ge 0 then mo08 = t3346201;
   if t3346202 ge 0 then yr08 = t3346202;
   if t3507300 ge 0 then self08 = t3507300;
end;
if t2009700 = 3 then do;
   if t2017900 ge 0 then wage08 = t2017900/100;
   if t2018700 ge 0 then hours08 = t2018700;
   if t3330300 ge 0 then curr08 = t3330300;
   if t3346301 ge 0 then mo08 = t3346301;
   if t3346302 ge 0 then yr08 = t3346302;
   if t3507400 ge 0 then self08 = t3507400;
end;
if t2009700 = 6 then do;
   if t2018200 ge 0 then wage08 = t2018200/100;
   if t2019000 ge 0 then hours08 = t2019000;
   if t3330600 ge 0 then curr08 = t3330600;
   if t3346601 ge 0 then mo08 = t3346601;
   if t3346602 ge 0 then yr08 = t3346602;
   if t3507700 ge 0 then self08 = t3507700;
end;

*convert wages to 2008 dollars;
if wage08 gt 0 then do;
   if yr08 = 2007 then wage08 = wage08*(215.303/207.342);
   if yr08 = 2009 then wage08 = wage08*(215.303/214.537);
end;

lnw08 = .;
lnw08 = log(wage08);

**calculate age on the job;
*I am going to take the current/most recent job for 2008, then figure out if at least 24
*when held it;
agej08 = .;
if mo08 gt 0 and yr08 gt 0 then do;
   agej08 = yr08 - r0536402;
   if r0536401 gt mo08 then agej08 = agej08 - 1;
end;
if r0000100 = 8918 then agej08 = 24;

agej24 = 0;
agej25 = 0;
agej26 = 0;
if agej08 = 24 then agej24 = 1;
if agej08 = 25 then agej25 = 1;
if agej08 = 26 then agej26 = 1;

**full time or part time;
pt08 = .;
ft08 = .;
if (hours08 ge 1 and hours08 le 34) then do;
    pt08 = 1;
	ft08 = 0;
end;
if (hours08 ge 35) then do;
    pt08 = 0;
	ft08 = 1;
end;

**sampling weight;
wt08 = .;
wt08 = t2022500/100;

**create dummy variables for missing;
expedv = 0;
if exp20e = . then expedv = 1;

expadv = 0;
if exp20a = . then expadv = 1;

famdv = 0;
if twobio97 = . then famdv = 1;

daddv = 0;
if biodaded = . then daddv = 1;

momdv = 0;
if biomomed = . then momdv = 1;

hhincdv = 0;
if lnhhinc = . then hhincdv = 1;

*deletions;
if piat97 ne .;
if black ne .;
if age08 ge 24;
if agej08 ge 24 and agej08 le 26;
if wage08 ne .;
if wage08 ge 3 and wage08 le 250;
if self08 ne 1;
if hgc08 ne .;
if hours08 gt 0;
**so few of these, will stick to birth years 1982-84;
if b80 ne 1;
if b81 ne 1;
**;


proc means;
run;
